#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int main()
{
    int year = 0, month = 0, day = 0;
    cin >> year >> month >> day;
    int GetDay[] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 };
    int Sum = GetDay[month - 1];
    Sum += day;
    if (month > 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        ++Sum;
    }
    cout << Sum << endl;
    return 0;
}

